package com.lewa.os.ui;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.GradientDrawable.Orientation;
import android.support.lewa.view.LewaPagerView.OnPageChangeListener;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;

public class ViewPagerIndicator extends RelativeLayout
  implements LewaPagerView.OnPageChangeListener
{
  private static final int PADDING = 5;
  int mArrowPadding;
  int mCurItem;
  TextView mCurrent;
  ImageView mCurrentIndicator;
  private GradientDrawable mFadingEdgeLeft;
  private GradientDrawable mFadingEdgeRight;
  int[] mFocusedTextColor;
  TextView mNext;
  ImageView mNextArrow;
  LinearLayout mNextGroup;
  OnClickListener mOnClickHandler;
  PageInfoProvider mPageInfoProvider;
  ImageView mPrevArrow;
  TextView mPrevious;
  LinearLayout mPreviousGroup;
  int mSize;
  int[] mUnfocusedTextColor;
  OnPagerSlidingListener pagerTrigger;

  public ViewPagerIndicator(Context paramContext)
  {
    super(paramContext);
    addContent();
  }

  public ViewPagerIndicator(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    addContent();
  }

  public ViewPagerIndicator(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
  {
    super(paramContext, paramAttributeSet, paramInt);
    addContent();
  }

  private void addContent()
  {
    this.mFocusedTextColor = new int[] { 0, 0, 0 };
    this.mUnfocusedTextColor = new int[] { 190, 190, 190 };
    this.mPrevious = new TextView(getContext());
    this.mCurrent = new TextView(getContext());
    this.mNext = new TextView(getContext());
    RelativeLayout.LayoutParams localLayoutParams1 = new RelativeLayout.LayoutParams(-2, -2);
    localLayoutParams1.addRule(5);
    RelativeLayout.LayoutParams localLayoutParams2 = new RelativeLayout.LayoutParams(-2, -2);
    localLayoutParams2.addRule(14);
    RelativeLayout.LayoutParams localLayoutParams3 = new RelativeLayout.LayoutParams(-2, -2);
    localLayoutParams3.addRule(11);
    this.mPreviousGroup = new LinearLayout(getContext());
    this.mPreviousGroup.setOrientation(0);
    this.mNextGroup = new LinearLayout(getContext());
    this.mNextGroup.setOrientation(0);
    this.mPreviousGroup.addView(this.mPrevious, new RelativeLayout.LayoutParams(-2, -2));
    this.mNextGroup.addView(this.mNext, new RelativeLayout.LayoutParams(-2, -2));
    addView(this.mPreviousGroup, localLayoutParams1);
    addView(this.mCurrent, localLayoutParams2);
    addView(this.mNextGroup, localLayoutParams3);
    this.mPrevious.setSingleLine();
    this.mCurrent.setSingleLine();
    this.mNext.setSingleLine();
    this.mPrevious.setText("previous");
    this.mCurrent.setText("current");
    this.mNext.setText("next");
    this.mPrevious.setTextSize(15.0F);
    this.mCurrent.setTextSize(15.0F);
    this.mNext.setTextSize(15.0F);
    this.mPrevious.setClickable(false);
    this.mNext.setClickable(false);
    this.mCurrent.setClickable(true);
    this.mPreviousGroup.setClickable(true);
    this.mNextGroup.setClickable(true);
    updateColor(0);
    this.mNext.setTextColor(-7829368);
    this.mPrevious.setTextColor(-7829368);
  }

  int adjustOffset(int paramInt)
  {
    return ((paramInt + getWidth() / 2) % getWidth() - (getWidth() / 2));
  }

  protected void dispatchDraw(Canvas paramCanvas)
  {
    super.dispatchDraw(paramCanvas);
    this.mFadingEdgeLeft.draw(paramCanvas);
    this.mFadingEdgeRight.draw(paramCanvas);
  }

  public int getCurrentPosition()
  {
    return this.mCurItem;
  }

  public void init(int paramInt1, int paramInt2, PageInfoProvider paramPageInfoProvider, int paramInt3, int paramInt4)
  {
    int i;
    int j;
    setPageInfoProvider(paramPageInfoProvider);
    this.mSize = paramInt2;
    setText(paramInt1 - 1);
    this.mCurItem = paramInt1;
    int[] arrayOfInt = { -1184275, 16777215 };
    this.mFadingEdgeLeft = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, arrayOfInt);
    this.mFadingEdgeRight = new GradientDrawable(GradientDrawable.Orientation.RIGHT_LEFT, arrayOfInt);
    if (paramInt3 > 160)
      if (paramInt4 > 0)
      {
        i = 800;
        j = 20;
      }
    for (int k = 39; ; k = 25)
    {
      while (true)
      {
        this.mFadingEdgeLeft.setBounds(0, 0, j, k);
        this.mFadingEdgeRight.setBounds(i - j, 0, i, k);
        return;
        i = 480;
        j = 20;
        k = 39;
        continue;
        if (paramInt4 <= 0)
          break;
        i = 480;
        j = 13;
        k = 25;
      }
      i = 320;
      j = 13;
    }
  }

  public void onPageScrollStateChanged(int paramInt)
  {
    if (paramInt != 2)
      return;
    this.mCurrent.setText("");
  }

  public void onPageScrolled(int paramInt1, float paramFloat, int paramInt2)
  {
    int i = adjustOffset(paramInt2);
    updatePositions(i);
    updateColor(i);
    updateArrows(paramInt1);
    setText(-1 + updatePosition(paramInt1, i));
  }

  public void onPageSelected(int paramInt)
  {
    this.mCurrent.setPadding(0, 0, 0, 0);
    this.mCurItem = paramInt;
    if (this.pagerTrigger == null)
      return;
    this.pagerTrigger.onChangePagerTrigger(paramInt);
  }

  public void setArrows(Drawable paramDrawable1, Drawable paramDrawable2)
  {
    this.mPrevArrow = new ImageView(getContext());
    this.mPrevArrow.setImageDrawable(paramDrawable1);
    this.mNextArrow = new ImageView(getContext());
    this.mNextArrow.setImageDrawable(paramDrawable2);
    LinearLayout.LayoutParams localLayoutParams = new LinearLayout.LayoutParams(-2, -2);
    localLayoutParams.gravity = 17;
    this.mPreviousGroup.removeAllViews();
    this.mPreviousGroup.addView(this.mPrevArrow, localLayoutParams);
    this.mPreviousGroup.addView(this.mPrevious, localLayoutParams);
    this.mPrevious.setPadding(5, 0, 0, 0);
    this.mNext.setPadding(0, 0, 5, 0);
    this.mArrowPadding = (5 + paramDrawable1.getIntrinsicWidth());
    this.mNextGroup.addView(this.mNextArrow, localLayoutParams);
    updateArrows(this.mCurItem);
  }

  public void setFocusedTextColor(int[] paramArrayOfInt)
  {
    System.arraycopy(paramArrayOfInt, 0, this.mFocusedTextColor, 0, 3);
    updateColor(0);
  }

  public void setOnClickListener(OnClickListener paramOnClickListener)
  {
    this.mOnClickHandler = paramOnClickListener;
    this.mPreviousGroup.setOnClickListener(new OnPreviousClickedListener());
    this.mCurrent.setOnClickListener(new OnCurrentClickedListener());
    this.mNextGroup.setOnClickListener(new OnNextClickedListener());
  }

  public void setOnTriggerListener(OnPagerSlidingListener paramOnPagerSlidingListener)
  {
    this.pagerTrigger = paramOnPagerSlidingListener;
  }

  public void setPageInfoProvider(PageInfoProvider paramPageInfoProvider)
  {
    this.mPageInfoProvider = paramPageInfoProvider;
  }

  void setText(int paramInt)
  {
    if (paramInt < 0)
      this.mPrevious.setText("");
    while (true)
    {
      this.mCurrent.setText(this.mPageInfoProvider.getTitle(paramInt + 1));
      if (paramInt + 2 != this.mSize)
        break;
      this.mNext.setText("");
      return;
      this.mPrevious.setText(this.mPageInfoProvider.getTitle(paramInt));
    }
    this.mNext.setText(this.mPageInfoProvider.getTitle(paramInt + 2));
  }

  public void setUnfocusedTextColor(int[] paramArrayOfInt)
  {
    System.arraycopy(paramArrayOfInt, 0, this.mUnfocusedTextColor, 0, 3);
    this.mNext.setTextColor(-16777216);
    this.mPrevious.setTextColor(-16777216);
    updateColor(0);
  }

  void updateArrows(int paramInt)
  {
    int j;
    ImageView localImageView2;
    int i = 4;
    if (this.mPrevArrow != null)
    {
      ImageView localImageView1 = this.mPrevArrow;
      if (paramInt != 0)
        break label50;
      j = i;
      label21: localImageView1.setVisibility(j);
      localImageView2 = this.mNextArrow;
      if (paramInt != -1 + this.mSize)
        break label56;
    }
    while (true)
    {
      localImageView2.setVisibility(i);
      return;
      label50: j = 0;
      break label21:
      label56: i = 0;
    }
  }

  void updateColor(int paramInt)
  {
    float f1;
    int i = Math.abs(paramInt);
    int j = getWidth();
    if (j == 0)
      f1 = 0.0F;
    while (true)
    {
      float f2 = Math.min(1.0F, f1);
      (int)(f2 * this.mUnfocusedTextColor[0] + this.mFocusedTextColor[0] * (1.0F - f2));
      (int)(f2 * this.mUnfocusedTextColor[1] + this.mFocusedTextColor[1] * (1.0F - f2));
      (int)(f2 * this.mUnfocusedTextColor[2] + this.mFocusedTextColor[2] * (1.0F - f2));
      this.mCurrent.setTextColor(-16777216);
      return;
      f1 = i / j / 4.0F;
    }
  }

  int updatePosition(int paramInt1, int paramInt2)
  {
    if (paramInt2 < 0)
      return (paramInt1 + 1);
    return paramInt1;
  }

  void updatePositions(int paramInt)
  {
    int i = this.mCurrent.getWidth() - this.mCurrent.getPaddingLeft() - this.mCurrent.getPaddingRight();
    int j = getWidth() / 2 - (i / 2) - this.mArrowPadding;
    if (paramInt > 0)
    {
      int i1 = Math.min(paramInt, -1 + j - getPaddingLeft());
      this.mCurrent.setPadding(0, 0, i1 * 2, 0);
      int i2 = this.mPreviousGroup.getRight() - this.mCurrent.getLeft() + this.mArrowPadding;
      this.mPreviousGroup.setPadding(-Math.max(0, i2), 0, Math.max(0, i2), 0);
      this.mNextGroup.setPadding(0, 0, 0, 0);
      return;
    }
    int k = Math.max(paramInt, -(j - getPaddingRight()));
    this.mCurrent.setPadding(k * -2, 0, 0, 0);
    int l = this.mCurrent.getRight() - this.mNextGroup.getLeft() + this.mArrowPadding;
    this.mNextGroup.setPadding(Math.max(0, l), 0, -Math.max(0, l), 0);
    this.mPreviousGroup.setPadding(0, 0, 0, 0);
  }

  public static abstract interface OnClickListener
  {
    public abstract void onCurrentClicked(View paramView);

    public abstract void onNextClicked(View paramView);

    public abstract void onPreviousClicked(View paramView);
  }

  class OnCurrentClickedListener
    implements View.OnClickListener
  {
    public void onClick(View paramView)
    {
      if (ViewPagerIndicator.this.mOnClickHandler == null)
        return;
      ViewPagerIndicator.this.mOnClickHandler.onCurrentClicked(ViewPagerIndicator.this);
    }
  }

  class OnNextClickedListener
    implements View.OnClickListener
  {
    public void onClick(View paramView)
    {
      if (ViewPagerIndicator.this.mOnClickHandler == null)
        return;
      ViewPagerIndicator.this.mOnClickHandler.onNextClicked(ViewPagerIndicator.this);
    }
  }

  public static abstract interface OnPagerSlidingListener
  {
    public abstract void onChangePagerTrigger(int paramInt);
  }

  class OnPreviousClickedListener
    implements View.OnClickListener
  {
    public void onClick(View paramView)
    {
      if (ViewPagerIndicator.this.mOnClickHandler == null)
        return;
      ViewPagerIndicator.this.mOnClickHandler.onPreviousClicked(ViewPagerIndicator.this);
    }
  }

  public static abstract interface PageInfoProvider
  {
    public abstract String getTitle(int paramInt);
  }
}

/* Location:           H:\360云盘\lewa_explorer_3.0\bin\FileApp_orig_dex2jar.jar
 * Qualified Name:     com.lewa.os.ui.ViewPagerIndicator
 * JD-Core Version:    0.5.2
 */